using System;
using System.Drawing;
using System.IO;
using System.Xml;

namespace PacSnake
{
	/// <summary>
	/// The Skin object determines the look of the game. Each skin will have
	/// different images for the level and the snake, the background or the
	/// background color.
	/// </summary>
	public class Skin
	{
	    private string name = string.Empty;
	    private string directory = string.Empty;
	    private string author = string.Empty;
	    private string filename = string.Empty;
		
		private Image background;
		private Image food;
		private Image snakeCornerLL;
		private Image snakeHeadR;
		private Image snakeTailR;
		private Image snakeStraightH;
		private Image wallCross;
		private Image wallCornerLL;
		private Image wallCornerLR;
		private Image wallCornerUL;
		private Image wallCornerUR;
		private Image wallTLeft;
		private Image wallTRight;
		private Image wallTUp;
		private Image wallTDown;
		private Image wallStraightH;
		private Image wallStraightV;

		
		/// <summary>
		/// Loads the skin information from an XML skin file
		/// </summary>
		/// <param name="skinFilename">Filename to load from</param>
		public void LoadSkin(string skinFilename)
		{
            XmlDocument doc = new XmlDocument();
            doc.Load(skinFilename);
            
            name = doc.SelectSingleNode("//Name").InnerText;
            directory = doc.SelectSingleNode("//Directory").InnerText;
            author = doc.SelectSingleNode("//Author").InnerText;
            filename = skinFilename;
            
            string path = "skins\\" + directory + "\\";
            background = Image.FromFile(path + "background.gif");
            food = Image.FromFile(path + "food.gif");
            snakeCornerLL = Image.FromFile(path + "snakecornerll.gif");
            snakeHeadR = Image.FromFile(path + "snakeheadr.gif");
            snakeTailR = Image.FromFile(path + "snaketailr.gif");
            snakeStraightH = Image.FromFile(path + "snakestraighth.gif");
            wallCross = Image.FromFile(path + "wallcross.gif");
            wallCornerLL = Image.FromFile(path + "wallll.gif");
            wallCornerLR = Image.FromFile(path + "walllr.gif");
            wallCornerUL = Image.FromFile(path + "wallul.gif");
            wallCornerUR = Image.FromFile(path + "wallur.gif");
            wallTLeft = Image.FromFile(path + "walltl.gif");
            wallTRight = Image.FromFile(path + "walltr.gif");
            wallTUp = Image.FromFile(path + "walltu.gif");
            wallTDown = Image.FromFile(path + "walltd.gif");
            wallStraightH = Image.FromFile(path + "wallhor.gif");
            wallStraightV = Image.FromFile(path + "wallver.gif");
		}
		
		#region Properties
		
        public string Name
        {
            get { return name; }
        }
        
        public string Directory
        {
            get { return directory; }
        }
        
        public string Author
        {
            get { return author; }
        }
        
        public string Filename
        {
            get { return filename; }
        }
        
        public Image Background
        {
            get { return background; }
        }
        
        public Image Food
        {
            get { return food; }
        }
        
        public Image SnakeCornerLL
        {
            get { return snakeCornerLL; }
        }
        
        public Image SnakeHeadR
        {
            get { return snakeHeadR; }
        }
        
        public Image SnakeTailR
        {
            get { return snakeTailR; }
        }
        
        public Image SnakeStraightH
        {
            get { return snakeStraightH; }
        }
        
        public Image WallCross
        {
            get { return wallCross; }
        }
        
        public Image WallCornerLL
        {
            get { return wallCornerLL; }
        }
        
        public Image WallCornerLR
        {
            get { return wallCornerLR; }
        }
        
        public Image WallCornerUL
        {
            get { return wallCornerUL; }
        }
        
        public Image WallCornerUR
        {
            get { return wallCornerUR; }
        }
        
        public Image WallTLeft
        {
            get { return wallTLeft; }
        }
        
        public Image WallTRight
        {
            get { return wallTRight; }
        }
        
        public Image WallTUp
        {
            get { return wallTUp; }
        }
        
        public Image WallTDown
        {
            get { return wallTDown; }
        }
        
        public Image WallStraightH
        {
            get { return wallStraightH; }
        }
        
        public Image WallStraightV
        {
            get { return wallStraightV; }
        }
        
        #endregion
	}
}
